package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkSpaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @Author 梁科
 * @Version 1.0
 * @ Date 2025/10/31 20:13
 */
@Slf4j
@Api(tags = "工作台相关接口")
@RequestMapping(value = "/admin/workspace")
@RestController
public class WorkSpaceController {
    @Resource
    private WorkSpaceService workSpaceService;

    /**
     * 工作台查询今日运营数据
     *
     * @return
     */
    @ApiOperation(value = "查询今日运营数据")
    @GetMapping(value = "/businessData")
    public Result<BusinessDataVO> businessData() {
        LocalDate date = LocalDate.now();
        LocalDateTime begin = LocalDateTime.of(date, LocalTime.MIN);
        LocalDateTime end = LocalDateTime.of(date, LocalTime.MAX);
        log.info("begin = {},end = {}", begin, end);
        BusinessDataVO businessDataVO = workSpaceService.getBusinessData(begin, end);
        return Result.success(businessDataVO);
    }

    /**
     * 工作台查看订单管理数据
     * @return
     */
    @GetMapping(value = "/overviewOrders")
    @ApiOperation(value = "工作台查看订单管理数据")
    public Result<OrderOverViewVO> overviewOrders() {
        OrderOverViewVO orderOverViewVO = workSpaceService.overviewOrders();
        return Result.success(orderOverViewVO);
    }

    /**
     * 工作台查看菜品总览数据
     * @return
     */
    @ApiOperation(value = "工作台查看菜品总览数据")
    @GetMapping(value = "/overviewDishes")
    public Result<DishOverViewVO> overviewDishes(){
        DishOverViewVO dishOverViewVO = workSpaceService.dishOverView();
        return Result.success(dishOverViewVO);
    }

    /**
     * 工作台查看套餐总览数据
     * @return
     */
    @ApiOperation(value = "工作台查看套餐总览数据")
    @GetMapping(value = "/overviewSetmeals")
    public Result<SetmealOverViewVO> overviewSetmeals(){
        SetmealOverViewVO setmealOverViewVO = workSpaceService.overviewSetmeals();
        return Result.success(setmealOverViewVO);
    }
}
